{include file="index@index/head"}
<div class="container">
    <!--面包屑导航-->
    <nav class="row breadcrumb">
        <a class="breadcrumb-item" href="#">首页</a>
        <span class="breadcrumb-item ">在线报考</span>
    </nav>
    <div class="row flex-column bmform">
        <h1><span class="year"></span>年网上报名系统入口</h1>
        <p>报名信息填写请务必保证真实性、准确性、完整性</p>
        <div class="d-flex flex-row">
            <form method="post" action="/index/show/sendemail.html" data-type="ajax" class="lform">
                <div class="d-flex flex-row form-item">
                    <label for="bktype"><span>*</span>报考类型</label>
                    <select id="bktype" class="yx-op bktype" name="bktype" required>
                        <option value="0">请选择类型</option>
                        <option value="2">成人高考</option>
                        <option value="1">自学考试</option>
                        <option value="5">同等学历申硕</option>
                        <option value="3">网络教育</option>
                        <option value="4">国开电大</option>
                    </select>
                    <label for="bkaddr"><span>*</span>报考地区</label>
                    <select id="bkaddr" class="yx-op bkaddr" name="bkaddr" required>
                        <option value="-1">请选择地区</option>
                    </select>
                </div>

                <div class="d-flex flex-row form-item">
                    <label for="bkyx"><span>*</span>报考院校</label>
                    <select id="bkyx" class="yx-op" name="bkyx" required>
                        <option value="-1">请选择院校</option>
                    </select>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="bkcc"><span>*</span>报考层次</label>
                    <select id="bkcc" class="yx-op" name="bkcc" required>
                        <option value="-1">请选择层次</option>
                    </select>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="bkzy"><span>*</span>报考专业</label>
                    <select id="bkzy" class="yx-op" name="bkzy" required>
                        <option value="-1">请选择专业</option>
                    </select>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="name"><span>*</span>姓名</label>
                    <input id="name" class="form-control" type="text" name="name" placeholder="请输入姓名" maxlength="5" required>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="sex"><span>*</span>性别</label>
                    <select id="sex" class="" name="sex" required>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="certificates"><span>*</span>身份证号码</label>
                    <input id="certificates" type="text" class="" name="certificates" required>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="phone"><span>*</span>手机号码</label>
                    <input id="phone" type="text" class="" name="phone" required>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="xl"><span>*</span>目前学历</label>
                    <select id="xl" class="" name="xl" required>
                        <option value="初中及以下">初中及以下</option>
                        <option value="高中">高中</option>
                        <option value="专科">专科</option>
                        <option value="本科">本科</option>
                    </select>
                </div>
                <div class="d-flex flex-row form-item">
                    <label for="qq">QQ</label>
                    <input id="qq" type="text" class="" name="qq">
                    <span style="margin-top:20px;margin-left:11px;width: 44px;color:#777;">(选填)</span>
                </div>
                <div class="d-flex flex-row form-item select-address-box">
                    <label for="provice">所在地区</label>
                    <select id="provice" class="select-item text-truncate" name="provice">
                        <option value="-1">请选择省份</option>
                    </select>
                    <select id="city" class="select-item text-truncate" name="city">
                        <option value="-1">请选择城市</option>
                    </select>
                    <select id="area" class="select-item text-truncate" name="area">
                        <option value="-1">请选择县/区</option>
                    </select>
                    <span style="margin-top:20px;margin-left:11px;width: 44px;color:#777;">(选填)</span>
                </div>
                <div class="d-flex flex-row form-item address">
                    <label for="address">详细地址</label>
                    <textarea name="address" id="address" resize="none"></textarea>
                    <span>(选填)</span>
                </div>
                <div class="text-center">
                    <button class="submit-btn" type="submit">提交报名</button>
                </div>
            </form>

            <div class="bmxz-box">
                <h2>报名须知</h2>
                <ol class="notice-box notice-box-1">
                    <li>成考是全国统一考试，统一录取，录取流程跟全国普通高考一致，文凭跟普通高考文凭同等待遇；自学考试属国民教育系列，采取免入学政策，国家承认学历。</li>
                    <li>毕业学生颁发《中华人民共和国高等学校毕业证书》，符合条件的授予学士学位，毕业证书在学信网(<a class="text-danger" href="http://www.chsi.com.cn">www.chsi.com.cn</a>)上查询认证，可以考研，出国留学、评职称等。</li>
                    <li>预留信息为调研的重要依据，请务必准确、真实填写，以免给自己造成不必要的损失。</li>
                    <li>考生填写信息务必准确,真实，不要有弄虚作假行为，以免给自已和学校造成不必要的损失;</li>
                    <li>提示“提交成功”后，当地学业顾问将在24小时内对您的信息进行审核，并解答您的相关问题，请保持联系方式畅通。</li>
                </ol>
                <h2>注意事项</h2>
                <ol class="notice-box">
                    <li>在本平台填写的调研信息并不能作为正式报名使用。</li>
                    <li>本站填写调研信息不收取任何服务费用。</li>
                    <li>本站不从事任何报名、招生相关服务。</li>
                </ol>
                <div class="text-center wxcode">
                    <img src="__PUBLIC__/static/static/img/wx_2.jpg" alt="微信公众号">
                </div>
            </div>
        </div>
    </div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="__PUBLIC__/public/layer/layer.js"></script>
<script src="__PUBLIC__/static/static/js/area.js"></script>
<script>
//请求数据

/***初始状态***/
$("#bkaddr").attr("disabled",true); //报考类型、地区
$("#bkyx").attr("disabled",true);
$("#bkcc").attr("disabled",true);
$("#bkzy").attr("disabled",true);
$("#city").attr("disabled",true);//城市选择provice city area
$("#area").attr("disabled",true);
const bkaddrArr = ["北京","天津","河北","山西","内蒙古","辽宁","吉林","黑龙江","上海","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","广西","海南","重庆","四川","贵州","云南","西藏","陕西","甘肃","青海","宁夏","新疆"];


//报考类型、地区选择
let bkaddrOp = "";
let bktypeId = "-1";
let bkaddrId = "-1";
let bkccId = "-1";
let yxOp = "";
let bkyxId = "";
let ccOp = "";
let zyOp ="";
let yxzdata =[
    {
        "name":"中南财经政法大学",
        "cc":[{
            'name':"高升专",
            'zy':["投资学","金融学"]
        },{
            'name':"专升本",
            "zy":["酒店管理"]
        }]
    },{
        "name":"武汉大学",
        "cc":[{
            'name':"专升本",
            "zy":["汉语言文学"]
        }]
    }]
;
$("#bktype").change(function () {
    bkaddrOp = "";
    bktypeId = $("#bktype").val();
    $("#bkaddr").attr("disabled",true);
    $("#bkyx").attr("disabled",true);
    $("#bkcc").attr("disabled",true);
    $("#bkzy").attr("disabled",true);
    if(bktypeId!="-1"){
        $("#bkaddr").attr("disabled",false);
        //console.log(bktypeId);
        if(bktypeId=='2'){
            console.log(bkaddrArr);
            for(const i in bkaddrArr){
                bkaddrOp +="<option value='"+(parseInt(i)+1)+"'>" +bkaddrArr[i]+"</option>";
            }
        }else{
            $("#bkaddr").html("");
            $("#bkyx").attr("disabled",false);
            bkaddrOp = "<option value='0'>全国</option>";
        }
    }else{
        $("#bkaddr").html("");
        bkaddrOp = "<option value='-1'>请选择地区</option>";
    }
    $("#bkaddr").append(bkaddrOp);
});
//获取数据
// yxzdata = JSON.parse(yxzdata);

//data={type:'',addr:''}
function getYxzdata(data,success){
    $.ajax({
        url:"/obtain",
        type:"post",
        data:data,
        type:"POST",
        success:function (res) {
            success(res);
        }
    })
}
// 报考地区
$("#bkaddr").change(function () {
    //
    $("#bkyx").html("");
    yxOp = "<option value=\"-1\">请选择院校</option>";
    $("#bkyx").attr("disabled",true);
    $("#bkcc").attr("disabled",true);
    $("#bkzy").attr("disabled",true);
    bkaddrId = $("#bkaddr").val();
    if(bktypeId!='0'){
        $("#bkyx").attr("disabled",false);
        const bktype = $("#bktype").val();
        const bkaddr = $("#bkaddr").val();
        getYxzdata({type:bktype,city_id:bkaddr},function(res){
            console.log(res)
            yxzdata =JSON.parse(res);
            // yxzdata =res;
            console.log(yxzdata)
            for(var i in yxzdata){
                yxOp +="<option value='"+(parseInt(i+1))+"'>" +yxzdata[i].name+"</option>";
            }
            $("#bkyx").append(yxOp);
        });
    }
})
//报考院校选择
$("#bkyx").change(function () {
    $("#bkcc").html("");
    ccOp="<option value=\"-1\">请选择层次</option>";
    $("#bkcc").attr("disabled",true);
    $("#bkzy").attr("disabled",true);
    bkyxId = parseInt($("#bkyx").val()-1);
    if(bkyxId!='-1'){
        $("#bkcc").attr("disabled",false);
        console.log('bkyxId',bkyxId)
        console.log('123',yxzdata[bkyxId]['cc']);
        for(var i in yxzdata[bkyxId].cc){
            ccOp += "<option value='"+i+"'>" +yxzdata[bkyxId].cc[i].name+"</option>";
        }
        $("#bkcc").append(ccOp);
    }
})
//报考层次
$("#bkcc").change(function () {
    $("#bkzy").html("");
    zyOp="<option value=\"-1\">请选择专业</option>";
    $("#bkzy").attr("disabled",true);
    bkccId = $("#bkcc option:selected").val();
    if(bkccId!='-1'){
        $("#bkzy").attr("disabled",false);
        for(var i in yxzdata[bkyxId].cc[bkccId].zy){
            zyOp += "<option value='"+i+"'>" +yxzdata[bkyxId].cc[bkccId].zy[i]+"</option>";
        }
        $("#bkzy").append(zyOp);
    }
})


//城市选择provice city area
let proviceOp = "";
let cityOp = "";
let areaOp = "";
let proviceId = "";
let cityId = "";

for(var i in provinceList){
    proviceOp +="<option value='"+i+"'>"+ provinceList[i].name+"</option>";
}
$("#provice").append(proviceOp);

$("#provice").change(function () {
    cityOp = "<option value=\"-1\">请选择城市</option>";
    areaOp = "<option value=\"-1\">请选择县/区</option>";
    $("#city").html("");
    $("#area").html("");
    $("#area").append(areaOp);
    $("#city").attr("disabled",true);
    $("#area").attr("disabled",true);

    proviceId = $("#provice").val();
    if(proviceId!='-1'){
        $("#city").attr("disabled",false);
        for(var i in provinceList[proviceId].cityList){
            cityOp +="<option value='"+i+"'>"+ provinceList[proviceId].cityList[i].name+"</option>";
        }
    }
    $("#city").append(cityOp);
});

$("#city").change(function () {
    areaOp = "<option value=\"-1\">请选择县/区</option>";
    $("#area").html("");

    $("#area").attr("disabled",true);
    cityId = $("#city").val();
    if(cityId!='-1'){
        $("#area").attr("disabled",false);
        for(var i in provinceList[proviceId].cityList[cityId].areaList){
            areaOp +="<option value='"+i+"'>"+ provinceList[proviceId].cityList[cityId].areaList[i]+"</option>";
        }
    }
    $("#area").append(areaOp);
});


//提交
$(document).on('submit','form[data-type=ajax]',function(){
	var url = $(this).attr('action');

    if($("#bktype option:selected").val()=="-1"){
        layer.msg("请选择报考类型");
        return false;
    }
    if($("#bkaddr option:selected").val()=="-1"){
        layer.msg("请选择报考地区");
        return false;
    }
    if($("#bkyx option:selected").val()=="-1"){
        layer.msg("请选择报考院校");
        return false;
    }
    if($("#bkcc option:selected").val()=="-1"){
        layer.msg("请选择报考层次");
        return false;
    }
    if($("#bkzy option:selected").val()=="-1"){
        layer.msg("请选择报考专业");
        return false;
    }
	if($("#name").val()==""){ 
		layer.msg("请输入姓名");
		return false;
	}
	if($("#phone").val()==""){ 
		layer.msg("请输入手机");
		return false;
	}
	var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;	
	var phone = $("#phone").val();
	if (!phoneReg.test(phone)) {
		layer.msg('手机号码格式错误');
		return false;
	}
	var cidReg=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    var cid = $("#certificates").val();
    if(!cidReg.test(cid)){
        layer.msg('身份证格式错误');
        return false;
    }

    var type = $("#bktype").val().trim();//报考类型
    var enroll_city = $("#bkaddr option:selected").text().trim();//报考地区
    var school = $("#bkyx option:selected").text().trim();//报考学院
    var level = $("#bkcc option:selected").text().trim();//报考层次
    var major = $("#bkzy option:selected").text().trim();//报考专业
    var name = $("#name").val().trim();//姓名
    var gender = $("#sex").val().trim();//性别
    var identity_card = $("#certificates").val().trim();//身份证
    var phone = $("#phone").val().trim();//电话
    var education = $("#xl option:selected").text().trim();//学历
    var qq = $("#qq").val().trim();//qq
    var city = $("#provice option:selected").text()+'-'+$("#city option:selected").text()+'-'+$("#area option:selected").text().trim();//所在地区
    var address = $("#address").val().trim();//详细地址
    data = [
        {name:"type",value:type},
        {name:"enroll_city",value:enroll_city},
        {name:"school",value:school},
        {name:"level",value:level},
        {name:"major",value:major},
        {name:"name",value:name},
        {name:"gender",value:gender},
        {name:"identity_card",value:identity_card},
        {name:"phone",value:phone},
        {name:"education",value:education},
        {name:"qq",value:qq},
        {name:"city",value:city},
        {name:"address",value:address}
    ];
	$.post(url,data,function(res){
		if(res.code == 1){
			layer.msg(res.msg,function(){ window.location.reload(); });
		}else{
			layer.msg(res.msg);
		}
	},"JSON");
	return false;
});
$(function(){
	$.get('/index/show/getToken.html',function(res){
		$("#token").val(res.__token__);
	},'json');
	//年
    $(".year").text(new Date().getFullYear());
})
</script>
{include file="index@index/foot"}